
# -*- coding: utf-8 -*-#
#-------------------------------------------------------------------------------
# 建立者:        Young  
# Name:         demo6.11
# Description:
# Author:       $赵怡蕾
# Date:         2019/2/15
#-------------------------------------------------------------------------------

# 定义一个空字典
dict = { }
# 向字典中添加一个名为name的key，默认值是Bill，运行结果：Bill
print(dict.setdefault("name",'Bill'))
# 运行结果：{'name': 'Bill'}
print(dict)
# 并没有改变name的值，运行结果：Bill
print(dict.setdefault("name",'Mike'))
# 运行结果：{'name': 'Bill'}
print(dict)
# 向字典中添加一个名为age的key，默认值是None，运行结果：None
print(dict.setdefault("age"))
# 运行结果：{'name': 'Bill', 'age': None}
print(dict)